package cn.com.thinvent.dispatch.web.utils;

public class UserContext {

    private static ThreadLocal<Integer> threadLocal = new ThreadLocal<>();

    /**
     * 设置用户id
     * @param id
     */
    public static void put(Integer id) {
        threadLocal.set(id);
    }

    /**
     * 获取用户id
     * @return
     */
    public static Integer get() {
        return threadLocal.get();
    }

    /**
     * 移除用户id 防止内存泄漏
     */
    public static void remove() {
        threadLocal.remove();
    }

}
